home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / installboot / installsun.c < prev    next >
C/C++ Source or Header  |  1991-01-14  |  2KB  |  64 lines

  1. /* 
  2.  * installsun.c --
  3.  *
  4.  *    Check the header of a coff? file.
  5.  *
  6.  * Copyright 1990 Regents of the University of California
  7.  * All rights reserved.
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/src/admin/installboot/RCS/installsun.c,v 1.1 90/02/16 16:12:24 shirriff Exp $ SPRITE (Berkeley)";
  19. #endif
  20.  
  21. #include <sprite.h>
  22. #include <kernel/sun3.md/procMach.h>
  23. #include <stdio.h>
  24.  
  25.  
  26. /*
  27.  *----------------------------------------------------------------------
  28.  *
  29.  * SunHeader -
  30.  *
  31.  *    See if the boot program has a sun header.
  32.  *
  33.  * Results:
  34.  *    length of a.out header if succeeded, or -1 if there was an error.
  35.  *
  36.  * Side effects:
  37.  *    None.
  38.  *
  39.  *----------------------------------------------------------------------
  40.  */
  41. int
  42. SunHeader(bootFID, loadAddr, execAddr, length)
  43.     int bootFID;    /* Handle on the boot program */
  44.     Address *loadAddr;    /* Address to start loading boot program. */
  45.     Address *execAddr;    /* Address to start executing boot program. */
  46.     int *length;    /* Length of boot program. */
  47. {
  48.     ProcExecHeader aout;
  49.     int bytesRead;
  50.  
  51.     if (lseek(bootFID,0,0)<0) {
  52.     perror("");
  53.     return -1;
  54.     }
  55.     bytesRead = read(bootFID, (char *)&aout, sizeof(ProcExecHeader));
  56.     if (bytesRead < 0 || aout.magic != PROC_OMAGIC) {
  57.     return -1;
  58.     }
  59.     *loadAddr = 0;
  60.     *execAddr = 0;
  61.     *length = aout.code + aout.data;
  62.     return sizeof(ProcExecHeader);
  63. }
  64.